﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Huirui.Cavan.Domain.MainBoundedContext.AttachmentModule;
using Huirui.Cavan.Domain.MainBoundedContext.PurchaseModule;

namespace Huirui.Cavan.Domain.MainBoundedContext.SearchModule
{
    public class SearchFactory
    {
        public static AreaSearch CreateAreaSearch(string code)
        {
            AreaSearch search = new AreaSearch();
            search.ID = code;
            search.CurrentPage = 0;
            return search;
        }

        public static AreaSearch CreateAreaSearch(string code, int level, bool isParentCode)
        {
            AreaSearch search = new AreaSearch();
            search.ParentCode = code;
            search.Level = level;
            search.CurrentPage = 0;
            return search;
        }

        public static AreaSearch CreateAreaSearch(int level)
        {
            AreaSearch search = new AreaSearch();
            search.Level = level;
            search.CurrentPage = 0;
            return search;
        }

        public static AreaSearch CreateAreaSearchBySpell(string spell)
        {
            AreaSearch search = new AreaSearch();
            search.Spell = spell;
            search.CurrentPage = 0;
            return search;
        }

        public static AttachmentSearch CreateAttachmentSearch(AttachmentIdentifier.AttachmentGroup group, int ownerID)
        {
            AttachmentSearch search = new AttachmentSearch();
            search.Group = group;
            search.OwnerID = ownerID;

            return search;
        }

        public static AttachmentSearch CreateAttachmentSearch(AttachmentIdentifier.AttachmentGroup group, AttachmentIdentifier.CheckedStatus checkedStatus)
        {
            AttachmentSearch search = new AttachmentSearch();
            search.Group = group;
            search.CheckedStatus = checkedStatus;

            return search;
        }

        public static NoticeSearch CreateNoticeSearch(IDictionary<string, bool> orderBy, int currentPage, int maxRowsPerPage)
        {
            NoticeSearch search = new NoticeSearch();
            search.OrderBy = orderBy;
            search.CurrentPage = currentPage;
            search.MaxRowsPerPage = maxRowsPerPage;

            return search;
        }

        public static UserAccountSearch CreateUserAccountSearch(string searchValue, SearchIdentifier.UserAccountSearchType searchType)
        {
            UserAccountSearch search = new UserAccountSearch();
            switch (searchType)
            {
                case SearchIdentifier.UserAccountSearchType.EmployeeCode: search.EmployeeCode = searchValue; break;
                case SearchIdentifier.UserAccountSearchType.Name: search.Name = searchValue; break;
                default: break;
            }

            return search;
        }

        public static EmployeeSearch CreateEmployeeSearch(string code, SearchIdentifier.Code codeType)
        {
            EmployeeSearch search = new EmployeeSearch();
            switch (codeType)
            {
                case SearchIdentifier.Code.EmployeeCode: search.ID = code; break;
                case SearchIdentifier.Code.CorporationCode: search.CorporationCode = code; break;
                case SearchIdentifier.Code.DepartmentCode: search.DepartmentCode = code; break;
                default: break;
            }
            search.CurrentPage = 0;
            return search;
        }

        public static EmployeeSearch CreateEmployeeSearch(int userAccountID)
        {
            EmployeeSearch search = new EmployeeSearch();
            search.UserAccountID = userAccountID;
            search.CurrentPage = 0;
            return search;
        }

        public static EmployeeSearch CreateEmployeeSearch(string code, string name)
        {
            EmployeeSearch search = new EmployeeSearch();
            search.ID = code;
            search.Name = name;
            search.CurrentPage = 0;
            return search;
        }

        public static AccountSearch CreateAccountSearch()
        {
            AccountSearch search = new AccountSearch();
            search.CurrentPage = 0;

            return search;
        }

        public static AccountInitialSearch CreateAccountInitialSearch(string currencyCode)
        {
            AccountInitialSearch search = new AccountInitialSearch();
            search.CurrencyCode = currencyCode;
            search.CurrentPage = 0;

            return search;
        }

        public static AccountInitialSearch CreateAccountInitialSearch()
        {
            AccountInitialSearch search = new AccountInitialSearch();
            search.CurrentPage = 0;

            return search;
        }

        public static CurrencySearch CreateCurrencySearch()
        {
            CurrencySearch search = new CurrencySearch();
            search.CurrentPage = 0;

            return search;
        }

        public static IndustryTypeSearch CreateIndustryTypeSearch()
        {
            IndustryTypeSearch search = new IndustryTypeSearch();
            search.CurrentPage = 0;

            return search;
        }

        public static CorporationSearch CreateCorporationSearch(string pCorporationCode)
        {
            CorporationSearch search = new CorporationSearch();
            search.Code = pCorporationCode;
            search.CurrentPage = 0;
            return search;
        }

        public static BaseCodeRuleSearch CreateBaseCodeRuleSearch()
        {
            BaseCodeRuleSearch search = new BaseCodeRuleSearch();
            search.CurrentPage = 0;

            return search;
        }

        public static BaseCodeRuleSearch CreateBaseCodeRuleSearch(int type)
        {
            BaseCodeRuleSearch search = new BaseCodeRuleSearch();
            search.CurrentPage = 0;
            search.Type = type;

            return search;
        }

        public static ReceiptCodeRuleSearch CreateReceiptCodeRuleSearch(int type)
        {
            ReceiptCodeRuleSearch search = new ReceiptCodeRuleSearch();
            search.CurrentPage = 0;
            search.Type = type;

            return search;
        }

        public static SystemConfigSearch CreateSystemConfigSearch()
        {
            SystemConfigSearch search = new SystemConfigSearch();
            search.CurrentPage = 0;

            return search;
        }

        public static DepartmentSearch CreateDepartmentSearch(string code,SearchIdentifier.Code codeType)
        {
            DepartmentSearch search = new DepartmentSearch();      
            switch (codeType)
            {
                case SearchIdentifier.Code.CorporationCode: search.CorporationCode = code; break;
                case SearchIdentifier.Code.DepartmentCode: search.Code = code; break;
                default: break;
            }
            search.CurrentPage = 0;
            return search;
        }

        public static DepartmentSearch CreateDepartmentSearch(string code, string name)
        {
            DepartmentSearch search = new DepartmentSearch();
            search.Code = code;
            search.Name = name;
            search.CurrentPage = 0;
            return search;
        }

        public static WareHouseSearch CreateWareHouseSearch()
        {
            WareHouseSearch search = new WareHouseSearch();
            search.CurrentPage = 0;

            return search;
        }

        public static CodeRulePropertySearch CreateCodeRulePropertySearch(int codeRuleID, int codeRuleType)
        {
            CodeRulePropertySearch search = new CodeRulePropertySearch();
            search.CodeRuleID = codeRuleID;
            search.CodeRuleType = codeRuleType;
            search.CurrentPage = 0;

            return search;
        }

        public static ManualCodeHistorySearch CreateManualCodeHistorySearch(string code, int codeRuleType, int codeType)
        {
            ManualCodeHistorySearch search = new ManualCodeHistorySearch();
            search.Code = code;
            search.CodeRuleType = codeRuleType;
            search.CodeType = codeType;
            search.CurrentPage = 0;

            return search;
        }

        public static StockInOutTypeSearch CreateStockInOutTypeSearch(bool isIn)
        {
            StockInOutTypeSearch search = new StockInOutTypeSearch();
            search.IsIn = isIn;
            search.CurrentPage = 0;

            return search;
        }

        public static StockSearch CreateStockSearch()
        {
            StockSearch search = new StockSearch();
            search.CurrentPage = 0;

            return search;
        }

        public static StockSearch CreateStockSearch(string name, string customerName, string supplierName)
        {
            StockSearch search = new StockSearch();
            search.CurrentPage = 0;
            search.Name = name;
            search.CustomerName = customerName;
            search.SupplierName = supplierName;

            return search;
        }

        public static StockInOutSearch CreateStockInSearch()
        {
            StockInOutSearch search = new StockInOutSearch();
            search.CurrentPage = 0;

            return search;
        }

        public static StockInOutSearch CreateStockInSearch(string purchaseOrderCode)
        {
            StockInOutSearch search = new StockInOutSearch();
            search.PurchaseOrderCode = purchaseOrderCode;
            search.CurrentPage = 0;

            return search;
        }

        public static StockInOutDetailSearch CreateStockInDetailSearch(string stockInCode)
        {
            StockInOutDetailSearch search = new StockInOutDetailSearch();
            search.CurrentPage = 0;

            return search;
        }

        public static StockInOutDetailSearch CreateStockInDetailSearch(string stockCode, bool hasLeft)
        {
            StockInOutDetailSearch search = new StockInOutDetailSearch();
            search.StockCode = stockCode;
            search.HasLeft = hasLeft;
            search.CurrentPage = 0;

            return search;
        }

        public static SupplierTypeSearch CreateSupplierTypeSearch()
        {
            SupplierTypeSearch search = new SupplierTypeSearch();
            search.CurrentPage = 0;

            return search;
        }

        public static SupplierTypeSearch CreateSupplierTypeSearch(string suppliertypename)
        {
            SupplierTypeSearch search = new SupplierTypeSearch();
            search.CurrentPage = 0;
            search.Name = suppliertypename;
            return search;
        }

        public static StockTypeSearch CreateStockTypeSearch()
        {
            StockTypeSearch search = new StockTypeSearch();
            search.CurrentPage = 0;

            return search;
        }

        public static StockTypeSearch CreateStockTypeSearch(string stocktypename)
        {
            StockTypeSearch search = new StockTypeSearch();
            search.CurrentPage = 0;
            search.Name = stocktypename;
            return search;
        }

        public static PurchaseReturnSearch CreatePurchaseReturnSearch(string purchaseId)
        {
            PurchaseReturnSearch search = new PurchaseReturnSearch();
            search.PurchaseId = purchaseId;
            search.CurrentPage = 0;

            return search;
        }

        public static UnPaySearch CreateUnPaySearch(DateTime? startDate, DateTime? endDate, string unPayCode, string supplierCode)
        {
            UnPaySearch search = new UnPaySearch();
            search.StartDate = startDate;
            search.EndDate = endDate;
            search.UnPayCode = unPayCode;
            search.SupplierCode = supplierCode;

            return search;
        }

        public static UnPaySearch CreateUnPaySearch(int unPayType, string unPayCode)
        {
            UnPaySearch search = new UnPaySearch();
            search.UnPayType = unPayType;
            search.UnPayCode = unPayCode;

            return search;
        }

        public static PaySearch CreatePaySearch(string payCode, DateTime? startDate, DateTime? endDate, string supplierCode)
        {
            PaySearch search = new PaySearch();
            search.ID = payCode;
            search.StartDate = startDate;
            search.EndDate = endDate;
            search.SupplierCode = supplierCode;

            return search;
        }

        public static PurchaseOrderSearch CreatePurchaseOrderSearch(DateTime? startDate, DateTime? endDate, string supplierCode, string purchaseOrderCode,
            string supplierInvoiceNumber, string purchaseEmployeeCode, string wareHouseCode, int? checkedStatus, int? stockInStatus)
        {
            PurchaseOrderSearch search = new PurchaseOrderSearch();
            search.CheckedStatus = checkedStatus;
            search.EndDate = endDate;
            search.ID = purchaseOrderCode;
            search.PurchaseEmployeeCode = purchaseEmployeeCode;
            search.StartDate = startDate;
            search.StockInStatus = stockInStatus;
            search.SupplierCode = supplierCode;
            search.SupplierInvoiceNumber = supplierInvoiceNumber;
            search.WareHouseCode = wareHouseCode;

            return search;
        }

        public static ReceivablesSearch CreateReceivablesSearch(int otherReceivablesType, string otherReceivablesCode)
        {
            ReceivablesSearch search = new ReceivablesSearch();
            search.ReceivablesCode = otherReceivablesCode;
            search.ReceivablesType = otherReceivablesType;

            return search;
        }

        public static ReceivablesSearch CreateReceivablesSearch(DateTime? startDate, DateTime? endDate, string receivablesCode, string customerCode)
        {
            ReceivablesSearch search = new ReceivablesSearch();
            search.StartDate = startDate;
            search.EndDate = endDate;
            search.ReceivablesCode = receivablesCode;
            search.CustomerCode = customerCode;

            return search;
        }

        public static SalesReturnSearch CreateSalesReturnSearch(string salesCode)
        {
            SalesReturnSearch search = new SalesReturnSearch();

            return search;
        }

        public static UnitTransferSearch CreateUnitTransferSearch(int fromStockUnitId, int toStockUnitId, decimal fromNumber, decimal toNumber)
        {
            UnitTransferSearch search = new UnitTransferSearch() { FromStockUnitID = fromStockUnitId, ToStockUnitID = toStockUnitId, FromNumber = fromNumber, ToNumber = toNumber };

            return search;
        }

        public static StockUnitSearch CreateStockUnitSearch()
        {
            StockUnitSearch search = new StockUnitSearch();

            return search;
        }

        public static SupplierSearch CreateSupplierSearch(string code, string name, string contact, int supplierTypeId, string areaCode)
        {
            SupplierSearch search = new SupplierSearch() { ID = code, Name = name, Contact = contact, SupplierTypeID = supplierTypeId, AreaCode = areaCode };
            search.CurrentPage = 0;

            return search;
        }

        public static CustomerSearch CreateCustomerSearch(string code, string name, string contact, int agentTypeId, string areaCode)
        {
            CustomerSearch search = new CustomerSearch() { ID = code, Name = name, Contact = contact, AgentTypeID = agentTypeId, AreaCode = areaCode };
            search.CurrentPage = 0;
            search.Status = true;
            return search;
        }

        public static JobSearch CreateJobSearch()
        {
            JobSearch search = new JobSearch();

            return search;
        }
    }
}
